package test;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.net.ssl.SSLSocket;

import communication.Request;
import communication.RequestInputStream;
import communication.RequestOutputStream;

public class SecureSocketConnection {

		private SSLSocket socket;
		private RequestOutputStream out;
		private RequestInputStream in;

		public SecureSocketConnection(SSLSocket socket) throws IOException {
			this.socket = socket;
			out = new RequestOutputStream(socket.getOutputStream());
			in = new RequestInputStream(socket.getInputStream());
		}

		public void writeRequest(Request request) throws IOException {
			out.writeRequest(request);
		}

		public Request readRequest() throws IOException, ClassNotFoundException {
			return in.readRequest();
		}

		public void close() throws IOException {
			socket.close();
		}

		public InputStream getInputStream() {
			
			return in;
		}
		
		public OutputStream getOutputStream(){
			return out;
		}
	}

